/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
#ifndef __MaCI_PlayerMainFrame__
#define __MaCI_PlayerMainFrame__

/**
@file
Subclass of MainFrame, which is generated by wxFormBuilder.
*/

#include "MaCI_Player_GUI.h"
#include "MaCI_PlayerAbout_Dialog.h"
#include "MaCI_PlayerGet_Name.h"
#include "MaCICtrlServer.hpp"
#include "ownutils.h"
#include "Component.hpp"
#include "gimi.h"
#include "Player.hpp"
#include <wx/filedlg.h>
#include <wx/timer.h>
#include "timestamp.hpp"

#include "PlayerModuleGenerator.hpp"
///Different player modules
#include "PlayerModule.hpp"
#include "PositionFilePlayer.hpp"
#include "RangingFilePlayer.hpp"
#include "SpeedCtrlFilePlayer.hpp"
#include "EnergyFilePlayer.hpp"
#include "WirelessFilePlayer.hpp"
#include "CoordinateDriveFilePlayer.hpp"
#include "IMUFilePlayer.hpp"
#include "ImageFilePlayer.hpp"

#define MAX_SPEED 128
#define MIN_SPEED 0.125

/** Implementing MainFrame */
class MaCI_PlayerMainFrame : public MainFrame,
                             public Gimbo::CComponent,
                             public wxTimer
{
protected:
	// Handlers for MainFrame events.
	void OnLoadLogFile( wxCommandEvent& event );
	void OnQuit( wxCommandEvent& event );
	void OnAbout( wxCommandEvent& event );
	void OnListItemSelected( wxListEvent& event );
        void OnListItemRClick( wxListEvent& event );
	void OnSliderScroll( wxScrollEvent& event );
	void OnPlayButtonClick( wxCommandEvent& event );
	void OnStopButtonClick( wxCommandEvent& event );
	void OnSlowerButtonClick( wxCommandEvent& event );
	void OnFasterButtonClick( wxCommandEvent& event );
        void OnSetMaCIGroupName( wxCommandEvent& event );
        void OnRepeatButtonClick( wxCommandEvent& event );
        //Gimbo
        void OnServiceAssignment(const Gimbo::TServiceAssignmentList &aServiceList);  
public:
	/** Constructor */
	MaCI_PlayerMainFrame( wxWindow* parent );
	virtual ~MaCI_PlayerMainFrame();

        bool Initialize(gimi::GIMI *aGimiPtr,int aGimboID, int aReportID);
        void Deinitialize(void);

        void Notify(); ///< Timer hit!
        // void CreateServer

 private:
        void CheckTotalTime(void);
        void CheckModuleTimes(void);
        wxString GetStringOfTime(gim::time aTime);
        PlayerModuleGenerator iPlayerModuleGenerator;
        bool iPlaying;
        float iPlayingSpeed;
        gimi::GIMI *iGimi;
        MaCI::MaCICtrl::CMaCICtrlServer *iMaCICtrlServer;
        Player iPlayer;
        std::string iVersionNumber;
        wxTimer iTimer;
        gim::time iTotalTime;
        int iRangingMinor;
        int iPositionMinor;
        int iSpeedCtrlMinor;
        int iIMUMinor;
        int iEnergyMinor;
        int iWirelessMinor;
        int iCoordinateDriveMinor;
        int iImageMinor;

};

#endif // __MaCI_PlayerMainFrame__
